﻿#region Copyright (c) 2012-10, Olaf Kober <amarok.projects@gmail.com>
//================================================================================
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.
//================================================================================
#endregion

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;


namespace Amarok
{
	/// <summary>
	/// This type represents a dictionary of Strings mapping to custom values. An appropriate equality comparer 
	/// must be specified on construction to define whether Strings are case sensitive, case insensitive or 
	/// culture-independent.
	/// </summary>
	/// 
	/// <typeparam name="TValue">
	/// The type of the values in the dictionary.</typeparam>
	[Serializable]
	public class StringDictionary<TValue> : Dictionary<String, TValue>
	{
		#region ++ Public Interface ++

		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		/// 
		/// <param name="comparer">
		/// The equality comparer to use when comparing keys.</param>
		/// 
		/// <exception cref="ArgumentNullException">
		/// A null reference was passed to a method that did not accept it as a valid argument.</exception>
		public StringDictionary(IEqualityComparer<String> comparer)
			: base(comparer)
		{
			Verify.NotNull(comparer, "comparer");
		}

		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		/// 
		/// <param name="capacity">
		/// The initial number of elements that the dictionary can contain.</param>
		/// <param name="comparer">
		/// The equality comparer to use when comparing keys.</param>
		/// 
		/// <exception cref="ArgumentOutOfRangeException">
		/// The specified capacity is less than 0.</exception>
		/// <exception cref="ArgumentNullException">
		/// A null reference was passed to a method that did not accept it as a valid argument.</exception>
		public StringDictionary(Int32 capacity, IEqualityComparer<String> comparer)
			: base(capacity, comparer)
		{
			Verify.NotNegative(capacity, "capacity");
			Verify.NotNull(comparer, "comparer");
		}

		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		/// 
		/// <param name="dictionary">
		/// A dictionary whose elements are copied to the new dictionary.</param>
		/// <param name="comparer">
		/// The equality comparer to use when comparing keys.</param>
		/// 
		/// <exception cref="ArgumentNullException">
		/// A null reference was passed to a method that did not accept it as a valid argument.</exception>
		public StringDictionary(IDictionary<String, TValue> dictionary, IEqualityComparer<String> comparer)
			: base(dictionary, comparer)
		{
			Verify.NotNull(dictionary, "dictionary");
			Verify.NotNull(comparer, "comparer");
		}

		#endregion

		#region ## Protected Interface ##

		/// <summary>
		/// Initializes a new instance of the System.Collections.Generic.Dictionary{TKey,TValue} class with 
		/// serialized data.
		/// </summary>
		/// 
		/// <param name="info">
		/// A System.Runtime.Serialization.SerializationInfo object containing the information required to 
		/// serialize the System.Collections.Generic.Dictionary{TKey,TValue}.</param>
		/// <param name="context">
		/// A System.Runtime.Serialization.StreamingContext structure containing the source and destination of the 
		/// serialized stream associated with the System.Collections.Generic.Dictionary{TKey,TValue}.</param>
		protected StringDictionary(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		#endregion

	}
}
